home *** CD-ROM | disk | FTP | other *** search
/ CD Actual Thematic 25: Programming / pc_actual_25.iso / Javascript / JavaScriptEditor / jse_en28.exe / %MAINDIR% / Library / Animated Text.js < prev    next >
Encoding:
JavaScript  |  2001-09-10  |  1.3 KB  |  50 lines

  1. // This script will go through a message one character at a
  2. // time and change the caps of that character. It
  3. // looks neat but if in a non fixed type font, it will
  4. // lose some of the effect.  Set "speedtogo" higher to
  5. // go slower and lower to go faster. Set a[1] and a[2]
  6. // to the sets of alternating caps you want.  I have
  7. // chosen a[1] to be all small and a[2] to be all big
  8. // but you can set then to anything.  Just make sure
  9. // you have them reversed in the a[2] or you will
  10. // lose effect.
  11.  
  12.  
  13. // Enjoy.
  14.  
  15. var count = -1;
  16. var counter;
  17. var nchar
  18. var speedtogo = 200
  19.  
  20. var a = new Array();
  21.  
  22. a[1] = "ZHANG MING YAO";
  23. a[2] = "zhang ming yao";
  24.  
  25. function capswitch() {
  26.  count++
  27.  if(count == 0){
  28.    document.wow.display.value = a[1]
  29.   }
  30.  if(count == 1){
  31.     document.wow.display.value = a[2].substring(0, 1) +
  32. a[1].substring(22, 1)
  33.     }
  34.  if(count > 1){
  35.    a[3] = a[1].substring(0, count - 1) + a[2].substring(count - 1,
  36. count) + a[1].substring(22, count)
  37.   document.wow.display.value = a[3]
  38.  }
  39.  if(count == a[1].length){
  40.     count = -1
  41.   }
  42.  
  43.      counter    = setTimeout("capswitch()",speedtogo);
  44.  
  45.  }
  46.  
  47. document.write("<FORM NAME=\"wow\">");
  48. document.write("<INPUT TYPE=\"TEXT\" NAME=\"display\" SIZE=\"22\">");
  49. document.write("</FORM>");
  50. capswitch();